local fuzhao = fk.CreateSkill {
  name = "th_fuzhao",
  tags = { Skill.Compulsory },
}

fuzhao:addEffect(fk.CardUseFinished, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(fuzhao.name) then
      if target and target:isAlive() and
      data.card and data.card:getEffectiveId() and not target:isKongcheng() then
        local events = {}
        player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
          local use = e.data
          if use.from == target then
            table.insert(events, e.id)
          end
        end, Player.HistoryTurn)
        local idx = table.indexOf(events, player.room.logic:getCurrentEvent().id)
        return idx >= 0 and idx % 2 == 1
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local showCard = Fk:getCardById(table.random(target:getCardIds(Player.Hand)))
    room:filterCard(showCard.id, target)
    target:showCards(showCard)
    if showCard.name == "fire__slash" then
      room:throwCard(showCard, fuzhao.name, target, target)
    else
      room:setCardMark(showCard, "@@th_fuzhao-turn", 1)
    end
  end,
})
fuzhao:addEffect(fk.AfterCardsMove, {
  can_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile then
        return true
      end
    end
  end,
  on_refresh = function(self, event, target, player, data)
    for _, move in ipairs(data) do
      if move.toArea == Card.DiscardPile then
        for _, info in ipairs(move.moveInfo) do
          local card = Fk:getCardById(info.cardId)
          if card:getMark("@@th_fuzhao-turn") ~= 0 and player.room:getCardArea(info.cardId) == Card.DiscardPile then
            player.room:setCardMark(card, "@@th_fuzhao-turn", 0)
          end
        end
      end
    end
  end
})
fuzhao:addEffect("filter", {
  card_filter = function(self, card, player)
    return card:getMark("@@th_fuzhao-turn") ~= 0
  end,
  view_as = function(self, player, card)
    return Fk:cloneCard("fire__slash", card.suit, card.number)
  end
})

Fk:loadTranslationTable{
  ["th_fuzhao"] = "辐照",
  [":th_fuzhao"] = "锁定技，一名角色本回合使用奇数张非虚拟牌后，其随机展示一张手牌，若为火【杀】，其弃置之，否则本回合此牌视为火【杀】直到进入弃牌堆。",

  ["@@th_fuzhao-turn"] = "辐照",
}

return fuzhao